use std::{time, thread::sleep};
use futures::executor::block_on;




#[test]
fn test_futures() {
    println!("00000");
    block_on(async {
        let f1 = r1();
        let f2 = r2();
        futures::join!(f1, f2);
    });
}


#[tokio::test]
async fn test_async() {
    println!("00000 test");
    // async_fn().await;
    // println!("11111 test");
    let context = tokio::fs::read("Cargo.toml").await.unwrap();
    println!("context: {:?}", String::from_utf8(context).unwrap());
    println!("11111 test");
}

#[tokio::test]
async fn test_async_join() {
    // let a = async {
        let r1 = r1();
        let r2 = r2();
        // tokio::join!(r1,r2);
        futures::join!(r1,r2);
}

async fn async_fn() {
    println!("22222 async");
    r1().await;
    println!("33333 async");
}

async fn r1() {
    println!("r1 start");
    sleep(time::Duration::from_secs(2));
    println!("r1");
}
async fn r2() {
    println!("r2 start");
    sleep(time::Duration::from_secs(2));
    println!("r2");
}